﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RW.Data.Objects
{
    public class IntegityCondition
    {
        public LogicStatement Condition { get; set; }
        public LogicStatement IfCondition { get; set; }
    }

    //Nazwa
    public class Problem
    {
        public List<string> Variables { get; set; }
        public List<Action> Actions { get; set; }

        public List<IntegityCondition> IntegrityConditions { get; set; }
        public LogicStatement InitialState { get; set; }
        public List<Observation> Observations { get; set; }

        public Problem(List<string> variables, List<Action> actions)
        {
            this.Variables = variables;
            this.Actions = actions;

            this.IntegrityConditions = new List<IntegityCondition>();
            this.Observations = new List<Observation>();
        }

        public bool CheckIntegrityConditions(State state)
        {
            bool result = true;

            foreach (IntegityCondition integrityCondition in this.IntegrityConditions)
                result &= !integrityCondition.IfCondition.Execute(state) || integrityCondition.Condition.Execute(state);

            return result;
        }

        public bool IsInitialState(State state)
        {
            if (this.InitialState == null)
                return false;

            return this.InitialState.Execute(state);
        }
    }
}
